﻿Public Class Main
    Inherits System.Web.UI.MasterPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub ButtonLogging_Click(sender As Object, e As EventArgs) Handles ButtonLogging.Click
        Dim svc As New IsisAssoWebServices.WebServicesClient
        Dim ReturnData As Long = svc.UserAccountLogging(My.Settings.pvkey, TextBoxLogin.Text, TextBoxPassword.Text)
        Select Case ReturnData
            '0 : no init
            '-1 : no account with this email exist
            '-2 : error processing creation
            'else : account ok with ID returning

            Case 0
                LabelErrorLogging.Text = "<br />Erreur du Serveur (000), veuillez recommencer"
                Case -1
                LabelErrorLogging.Text = "<br />Aucun compte n'existe avec cette adresse Email"
             Case -2
                LabelErrorLogging.Text = "<br />Erreur du Serveur (002), veuillez recommencer"
            Case Else

                
                Try
                    Dim ReturnData2 As IsisAssoWebServices.users = Nothing
                    ReturnData2 = svc.UserAccountDetail(My.Settings.pvkey, ReturnData)
                    Session.Contents("logged") = "yes"
                    Session.Contents("id_user") = ReturnData
                    Session.Contents("logged_name") = ReturnData2.user_prenom & " " & ReturnData2.user_nom
                Catch ex As Exception
                    LabelErrorLogging.Text = "Erreur du Serveur (003), veuillez recommencer"
                    Session.Abandon()
                End Try
        End Select
    End Sub
End Class